package com.photovoltaic.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.photovoltaic.auth.entity.Permission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PermissionMapper extends BaseMapper<Permission> {
    /**
     * 根据权限标识查询权限ID
     *
     * @param permissionKey 权限标识
     * @return 权限ID
     */
    @Select("SELECT id FROM permission WHERE permission_key = #{permissionKey}")
    Long getIdByKey(@Param("permissionKey") String permissionKey);
    
    /**
     * 根据多个权限标识查询权限ID列表
     *
     * @param permissionKeys 权限标识列表
     * @return 权限ID列表
     */
    @Select("<script>SELECT id FROM permission WHERE permission_key IN " +
            "<foreach item='key' collection='permissionKeys' open='(' separator=',' close=')'>" +
            "#{key}" +
            "</foreach></script>")
    List<Long> getIdsByKeys(@Param("permissionKeys") List<String> permissionKeys);
} 